package com.lzh.prometheus.config;

import com.google.gson.Gson;
import com.lzh.prometheus.httpclient.DefaultDingdingHttpClient;
import com.lzh.prometheus.httpclient.DingdingHttpClient;
import com.lzh.prometheus.properties.notice.DingDingNoticeProperty;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author zhehen.lu
 * @date 2025/8/15 9:34
 */
@Configuration
@ConditionalOnProperty(value = "prometheus.dingding.enabled", havingValue = "true")
@EnableConfigurationProperties({ DingDingNoticeProperty.class })
public class PromethuesDingDingNoticeConfig {

    @Bean
    @ConditionalOnMissingBean
    public DingdingHttpClient dingdingHttpClient(DingDingNoticeProperty dingDingNoticeProperty, Gson gson) {
        DingdingHttpClient dingdingHttpClient = new DefaultDingdingHttpClient(gson, dingDingNoticeProperty);
        return dingdingHttpClient;
    }
}
